package com.example.demo.web;

import com.alibaba.fastjson.JSON;
import com.example.demo.model.User;
import com.example.demo.shengchan.HelloSender1;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/rabbit")
public class RabbitTest {

    @Resource
    private HelloSender1 helloSender1;

    @GetMapping("/oneToMany")
    public void oneToMany() {
//        User user = new User();
//        user.setId("123");
//        user.setAge("23");
//        user.setName("cx");
//        String json = JSON.toJSONString(user);
        String json = "123";
        for (int i = 0; i < 10; i++) {
            helloSender1.send(json);
        }
    }

    @GetMapping("/status")
    public void status(String s) {
      helloSender1.receive();
    }

}
